import java.util.Date;

/**
 * Mode
 *
 * @author 28189
 * @since 2024/12/12 16:54
 */
public class Page {
    private String url;
    private int viewCount;
    private Date lastViewed;

    public Page(String url) {
        if (url == null) {
            throw new IllegalArgumentException("URL cannot be null");
        }
        this.url = url;
        this.viewCount = 0;
        this.lastViewed = null;
    }

    public Page(String url, int viewCount, Date lastViewed) {
        if (url == null) {
            throw new IllegalArgumentException("URL cannot be null");
        }
        this.url = url;
        this.viewCount = viewCount;
        this.lastViewed = lastViewed;
    }

    public String getUrl() {
        return url;
    }

    public void setUrl(String url) {
        if( url == null) {
            throw new IllegalArgumentException("URL cannot be null");
        }
        this.url = url;
    }

    public int getViewCount() {
        return viewCount;
    }

    public void setViewCount(int viewCount) {
        this.viewCount = viewCount;
    }

    public Date getLastViewed() {
        return lastViewed;
    }

    public void setLastViewed(Date lastViewed) {
        this.lastViewed = lastViewed;
    }
    public void increaseANDupdate(){
        this.viewCount++;
        this.lastViewed=new Date();
    }
}
